# coding=utf-8
# Copyright 2024 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Cirq code to construct circuit of 12 qubits.

This circuit generates the theoretical probability distribution of
2^{12}=4096 bitstrings in data/q12c0.txt

"""

from absl import app
from absl import logging

import cirq
import numpy as np


def get_probabilities(circuit):
  """Gets probabilities from the wave function."""
  output_state = cirq.sim.final_wavefunction(circuit)
  return np.abs(output_state) ** 2


def get_circuit():
  """Gets circuit."""
  q = cirq.LineQubit.range(12)

  circuit = cirq.Circuit.from_ops(
      *[
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          [cirq.X(q[1])**0.5, cirq.H(q[1])**0.5, cirq.X(q[1])**-0.5],
          [cirq.X(q[2])**0.5, cirq.H(q[2])**0.5, cirq.X(q[2])**-0.5],
          cirq.Y(q[3])**0.5,
          [cirq.X(q[4])**0.5, cirq.H(q[4])**0.5, cirq.X(q[4])**-0.5],
          cirq.Y(q[5])**0.5,
          cirq.X(q[6])**0.5,
          cirq.X(q[7])**0.5,
          cirq.X(q[8])**0.5,
          cirq.X(q[9])**0.5,
          cirq.Y(q[10])**0.5,
          [cirq.X(q[11])**0.5, cirq.H(q[11])**0.5, cirq.X(q[11])**-0.5],
          cirq.Rz(rads=0.2767373377033284*np.pi).on(q[1]),
          cirq.Rz(rads=-0.18492941569567625*np.pi).on(q[2]),
          cirq.Rz(rads=-1.00125113388313*np.pi).on(q[5]),
          cirq.Rz(rads=1.1224546746752684*np.pi).on(q[6]),
          cirq.Rz(rads=-0.33113463396189063*np.pi).on(q[9]),
          cirq.Rz(rads=0.40440704518468423*np.pi).on(q[10]),
          [
              cirq.ISWAP(q[1], q[2])**-1.009868884178167,
              cirq.CZ(q[1], q[2])**-0.16552586798219657,
          ],
          [
              cirq.ISWAP(q[5], q[6])**-0.9733750299685556,
              cirq.CZ(q[5], q[6])**-0.16091330726740966,
          ],
          [
              cirq.ISWAP(q[9], q[10])**-0.9769678680475263,
              cirq.CZ(q[9], q[10])**-0.16332605888196952,
          ],
          cirq.Rz(rads=-0.6722145774944012*np.pi).on(q[1]),
          cirq.Rz(rads=0.7640224995020534*np.pi).on(q[2]),
          cirq.Rz(rads=0.7990757781248072*np.pi).on(q[5]),
          cirq.Rz(rads=-0.6778722373326689*np.pi).on(q[6]),
          cirq.Rz(rads=0.049341949396894985*np.pi).on(q[9]),
          cirq.Rz(rads=0.02393046182589869*np.pi).on(q[10]),
          cirq.Y(q[0])**0.5,
          cirq.X(q[1])**0.5,
          cirq.Y(q[2])**0.5,
          [cirq.X(q[3])**0.5, cirq.H(q[3])**0.5, cirq.X(q[3])**-0.5],
          cirq.Y(q[4])**0.5,
          [cirq.X(q[5])**0.5, cirq.H(q[5])**0.5, cirq.X(q[5])**-0.5],
          cirq.Y(q[6])**0.5,
          cirq.Y(q[7])**0.5,
          cirq.Y(q[8])**0.5,
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          [cirq.X(q[10])**0.5, cirq.H(q[10])**0.5, cirq.X(q[10])**-0.5],
          cirq.Y(q[11])**0.5,
          cirq.Rz(rads=2.5333591271878086*np.pi).on(q[0]),
          cirq.Rz(rads=-2.4748096263683066*np.pi).on(q[1]),
          cirq.Rz(rads=-4.480708067260001*np.pi).on(q[2]),
          cirq.Rz(rads=4.525888267898699*np.pi).on(q[3]),
          cirq.Rz(rads=2.135954522972214*np.pi).on(q[4]),
          cirq.Rz(rads=-2.1822665205802965*np.pi).on(q[5]),
          cirq.Rz(rads=-3.7780476633662574*np.pi).on(q[6]),
          cirq.Rz(rads=3.817335880513747*np.pi).on(q[7]),
          cirq.Rz(rads=0.7811374803446167*np.pi).on(q[8]),
          cirq.Rz(rads=-0.6780279413275597*np.pi).on(q[9]),
          cirq.Rz(rads=1.863573798571082*np.pi).on(q[10]),
          cirq.Rz(rads=-2.150412392135508*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[0], q[1])**-0.8242343706275942,
              cirq.CZ(q[0], q[1])**-0.15468164635790926,
          ],
          [
              cirq.ISWAP(q[2], q[3])**-0.981653050634976,
              cirq.CZ(q[2], q[3])**-0.1933349989832593,
          ],
          [
              cirq.ISWAP(q[4], q[5])**-0.9637565510028211,
              cirq.CZ(q[4], q[5])**-0.15186761578643612,
          ],
          [
              cirq.ISWAP(q[6], q[7])**-1.0089894642925605,
              cirq.CZ(q[6], q[7])**-0.17298943435986638,
          ],
          [
              cirq.ISWAP(q[8], q[9])**-0.980271915828302,
              cirq.CZ(q[8], q[9])**-0.16470994863165317,
          ],
          [
              cirq.ISWAP(q[10], q[11])**-0.9290392306402181,
              cirq.CZ(q[10], q[11])**-0.1664963204791881,
          ],
          cirq.Rz(rads=-2.346072351850546*np.pi).on(q[0]),
          cirq.Rz(rads=2.404621852670048*np.pi).on(q[1]),
          cirq.Rz(rads=5.048199817882042*np.pi).on(q[2]),
          cirq.Rz(rads=-5.0030196172433445*np.pi).on(q[3]),
          cirq.Rz(rads=-2.6543362735839113*np.pi).on(q[4]),
          cirq.Rz(rads=2.6080242759758283*np.pi).on(q[5]),
          cirq.Rz(rads=3.9045088495271663*np.pi).on(q[6]),
          cirq.Rz(rads=-3.8652206323796765*np.pi).on(q[7]),
          cirq.Rz(rads=-1.5516585295358842*np.pi).on(q[8]),
          cirq.Rz(rads=1.6547680685529413*np.pi).on(q[9]),
          cirq.Rz(rads=-1.8933072151541963*np.pi).on(q[10]),
          cirq.Rz(rads=1.6064686215897703*np.pi).on(q[11]),
          cirq.X(q[0])**0.5,
          cirq.Y(q[1])**0.5,
          cirq.X(q[2])**0.5,
          cirq.Y(q[3])**0.5,
          cirq.X(q[4])**0.5,
          cirq.X(q[5])**0.5,
          cirq.X(q[6])**0.5,
          [cirq.X(q[7])**0.5, cirq.H(q[7])**0.5, cirq.X(q[7])**-0.5],
          cirq.X(q[8])**0.5,
          cirq.X(q[9])**0.5,
          cirq.X(q[10])**0.5,
          cirq.X(q[11])**0.5,
          cirq.Rz(rads=-3.2786928385561493*np.pi).on(q[4]),
          cirq.Rz(rads=3.339006443218924*np.pi).on(q[8]),
          cirq.Rz(rads=-5.390755870544794*np.pi).on(q[5]),
          cirq.Rz(rads=5.4172568990486605*np.pi).on(q[9]),
          cirq.Rz(rads=-5.620144773112766*np.pi).on(q[6]),
          cirq.Rz(rads=5.630469153514815*np.pi).on(q[10]),
          cirq.Rz(rads=4.367652291347506*np.pi).on(q[7]),
          cirq.Rz(rads=-3.9105776028384707*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[4], q[8])**-1.0121115249769066,
              cirq.CZ(q[4], q[8])**-0.16059979031178617,
          ],
          [
              cirq.ISWAP(q[5], q[9])**-0.985003985982119,
              cirq.CZ(q[5], q[9])**-0.16606010863938203,
          ],
          [
              cirq.ISWAP(q[6], q[10])**-0.9628319095031052,
              cirq.CZ(q[6], q[10])**-0.16339300450568622,
          ],
          [
              cirq.ISWAP(q[7], q[11])**-0.9999941453695372,
              cirq.CZ(q[7], q[11])**-0.16477879415124544,
          ],
          cirq.Rz(rads=2.9425087256630427*np.pi).on(q[4]),
          cirq.Rz(rads=-2.882195121000268*np.pi).on(q[8]),
          cirq.Rz(rads=4.466531408750767*np.pi).on(q[5]),
          cirq.Rz(rads=-4.440030380246901*np.pi).on(q[9]),
          cirq.Rz(rads=4.486471496440378*np.pi).on(q[6]),
          cirq.Rz(rads=-4.476147116038329*np.pi).on(q[10]),
          cirq.Rz(rads=-4.89701654221443*np.pi).on(q[7]),
          cirq.Rz(rads=5.354091230723465*np.pi).on(q[11]),
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          [cirq.X(q[1])**0.5, cirq.H(q[1])**0.5, cirq.X(q[1])**-0.5],
          [cirq.X(q[2])**0.5, cirq.H(q[2])**0.5, cirq.X(q[2])**-0.5],
          [cirq.X(q[3])**0.5, cirq.H(q[3])**0.5, cirq.X(q[3])**-0.5],
          [cirq.X(q[4])**0.5, cirq.H(q[4])**0.5, cirq.X(q[4])**-0.5],
          [cirq.X(q[5])**0.5, cirq.H(q[5])**0.5, cirq.X(q[5])**-0.5],
          cirq.Y(q[6])**0.5,
          cirq.Y(q[7])**0.5,
          [cirq.X(q[8])**0.5, cirq.H(q[8])**0.5, cirq.X(q[8])**-0.5],
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          cirq.Y(q[10])**0.5,
          [cirq.X(q[11])**0.5, cirq.H(q[11])**0.5, cirq.X(q[11])**-0.5],
          cirq.Rz(rads=12.703597923836748*np.pi).on(q[0]),
          cirq.Rz(rads=-12.7869629079138*np.pi).on(q[4]),
          cirq.Rz(rads=12.184253063938954*np.pi).on(q[1]),
          cirq.Rz(rads=-12.108584830758572*np.pi).on(q[5]),
          cirq.Rz(rads=3.782562501914174*np.pi).on(q[2]),
          cirq.Rz(rads=-3.873596611893716*np.pi).on(q[6]),
          cirq.Rz(rads=4.772639843256901*np.pi).on(q[3]),
          cirq.Rz(rads=-4.771314675186062*np.pi).on(q[7]),
          [
              cirq.ISWAP(q[0], q[4])**-0.933831313649303,
              cirq.CZ(q[0], q[4])**-0.1583933739924931,
          ],
          [
              cirq.ISWAP(q[1], q[5])**-0.9390847780661252,
              cirq.CZ(q[1], q[5])**-0.17144555428591543,
          ],
          [
              cirq.ISWAP(q[2], q[6])**-1.0209160715892363,
              cirq.CZ(q[2], q[6])**-0.14849009270439747,
          ],
          [
              cirq.ISWAP(q[3], q[7])**-1.0287988330229174,
              cirq.CZ(q[3], q[7])**-0.1385888562342036,
          ],
          cirq.Rz(rads=-12.477250219528523*np.pi).on(q[0]),
          cirq.Rz(rads=12.39388523545147*np.pi).on(q[4]),
          cirq.Rz(rads=-11.31088974563283*np.pi).on(q[1]),
          cirq.Rz(rads=11.386557978813212*np.pi).on(q[5]),
          cirq.Rz(rads=-5.4898636407973544*np.pi).on(q[2]),
          cirq.Rz(rads=5.398829530817813*np.pi).on(q[6]),
          cirq.Rz(rads=-5.863871460773714*np.pi).on(q[3]),
          cirq.Rz(rads=5.8651966288445525*np.pi).on(q[7]),
          cirq.X(q[0])**0.5,
          cirq.X(q[1])**0.5,
          cirq.Y(q[2])**0.5,
          cirq.X(q[3])**0.5,
          cirq.X(q[4])**0.5,
          cirq.X(q[5])**0.5,
          [cirq.X(q[6])**0.5, cirq.H(q[6])**0.5, cirq.X(q[6])**-0.5],
          [cirq.X(q[7])**0.5, cirq.H(q[7])**0.5, cirq.X(q[7])**-0.5],
          cirq.Y(q[8])**0.5,
          cirq.X(q[9])**0.5,
          cirq.X(q[10])**0.5,
          cirq.Y(q[11])**0.5,
          cirq.Rz(rads=5.16073733770325*np.pi).on(q[1]),
          cirq.Rz(rads=-5.068929415695599*np.pi).on(q[2]),
          cirq.Rz(rads=-4.701251133883051*np.pi).on(q[5]),
          cirq.Rz(rads=4.82245467467519*np.pi).on(q[6]),
          cirq.Rz(rads=-3.587134633961795*np.pi).on(q[9]),
          cirq.Rz(rads=3.6604070451845887*np.pi).on(q[10]),
          [
              cirq.ISWAP(q[1], q[2])**-1.009868884178167,
              cirq.CZ(q[1], q[2])**-0.16552586798219657,
          ],
          [
              cirq.ISWAP(q[5], q[6])**-0.9733750299685556,
              cirq.CZ(q[5], q[6])**-0.16091330726740966,
          ],
          [
              cirq.ISWAP(q[9], q[10])**-0.9769678680475263,
              cirq.CZ(q[9], q[10])**-0.16332605888196952,
          ],
          cirq.Rz(rads=-5.556214577494324*np.pi).on(q[1]),
          cirq.Rz(rads=5.648022499501975*np.pi).on(q[2]),
          cirq.Rz(rads=4.499075778124728*np.pi).on(q[5]),
          cirq.Rz(rads=-4.37787223733259*np.pi).on(q[6]),
          cirq.Rz(rads=3.305341949396799*np.pi).on(q[9]),
          cirq.Rz(rads=-3.232069538174005*np.pi).on(q[10]),
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          [cirq.X(q[1])**0.5, cirq.H(q[1])**0.5, cirq.X(q[1])**-0.5],
          cirq.X(q[2])**0.5,
          cirq.Y(q[3])**0.5,
          cirq.Y(q[4])**0.5,
          cirq.Y(q[5])**0.5,
          cirq.Y(q[6])**0.5,
          cirq.X(q[7])**0.5,
          [cirq.X(q[8])**0.5, cirq.H(q[8])**0.5, cirq.X(q[8])**-0.5],
          cirq.Y(q[9])**0.5,
          cirq.Y(q[10])**0.5,
          [cirq.X(q[11])**0.5, cirq.H(q[11])**0.5, cirq.X(q[11])**-0.5],
          cirq.Rz(rads=7.565359127187911*np.pi).on(q[0]),
          cirq.Rz(rads=-7.506809626368408*np.pi).on(q[1]),
          cirq.Rz(rads=-15.28470806725993*np.pi).on(q[2]),
          cirq.Rz(rads=15.329888267898626*np.pi).on(q[3]),
          cirq.Rz(rads=7.019954522972137*np.pi).on(q[4]),
          cirq.Rz(rads=-7.066266520580219*np.pi).on(q[5]),
          cirq.Rz(rads=-13.842047663366333*np.pi).on(q[6]),
          cirq.Rz(rads=13.881335880513822*np.pi).on(q[7]),
          cirq.Rz(rads=3.001137480344569*np.pi).on(q[8]),
          cirq.Rz(rads=-2.8980279413275123*np.pi).on(q[9]),
          cirq.Rz(rads=5.563573798571002*np.pi).on(q[10]),
          cirq.Rz(rads=-5.8504123921354285*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[0], q[1])**-0.8242343706275942,
              cirq.CZ(q[0], q[1])**-0.15468164635790926,
          ],
          [
              cirq.ISWAP(q[2], q[3])**-0.981653050634976,
              cirq.CZ(q[2], q[3])**-0.1933349989832593,
          ],
          [
              cirq.ISWAP(q[4], q[5])**-0.9637565510028211,
              cirq.CZ(q[4], q[5])**-0.15186761578643612,
          ],
          [
              cirq.ISWAP(q[6], q[7])**-1.0089894642925605,
              cirq.CZ(q[6], q[7])**-0.17298943435986638,
          ],
          [
              cirq.ISWAP(q[8], q[9])**-0.980271915828302,
              cirq.CZ(q[8], q[9])**-0.16470994863165317,
          ],
          [
              cirq.ISWAP(q[10], q[11])**-0.9290392306402181,
              cirq.CZ(q[10], q[11])**-0.1664963204791881,
          ],
          cirq.Rz(rads=-7.378072351850649*np.pi).on(q[0]),
          cirq.Rz(rads=7.436621852670151*np.pi).on(q[1]),
          cirq.Rz(rads=15.852199817881967*np.pi).on(q[2]),
          cirq.Rz(rads=-15.80701961724327*np.pi).on(q[3]),
          cirq.Rz(rads=-7.538336273583833*np.pi).on(q[4]),
          cirq.Rz(rads=7.492024275975751*np.pi).on(q[5]),
          cirq.Rz(rads=13.968508849527241*np.pi).on(q[6]),
          cirq.Rz(rads=-13.929220632379753*np.pi).on(q[7]),
          cirq.Rz(rads=-3.771658529535837*np.pi).on(q[8]),
          cirq.Rz(rads=3.874768068552894*np.pi).on(q[9]),
          cirq.Rz(rads=-5.593307215154117*np.pi).on(q[10]),
          cirq.Rz(rads=5.30646862158969*np.pi).on(q[11]),
          cirq.X(q[0])**0.5,
          cirq.X(q[1])**0.5,
          [cirq.X(q[2])**0.5, cirq.H(q[2])**0.5, cirq.X(q[2])**-0.5],
          cirq.X(q[3])**0.5,
          cirq.X(q[4])**0.5,
          [cirq.X(q[5])**0.5, cirq.H(q[5])**0.5, cirq.X(q[5])**-0.5],
          cirq.X(q[6])**0.5,
          cirq.Y(q[7])**0.5,
          cirq.X(q[8])**0.5,
          cirq.X(q[9])**0.5,
          [cirq.X(q[10])**0.5, cirq.H(q[10])**0.5, cirq.X(q[10])**-0.5],
          cirq.X(q[11])**0.5,
          cirq.Rz(rads=-8.162692838556204*np.pi).on(q[4]),
          cirq.Rz(rads=8.223006443218978*np.pi).on(q[8]),
          cirq.Rz(rads=-12.938755870544817*np.pi).on(q[5]),
          cirq.Rz(rads=12.965256899048683*np.pi).on(q[9]),
          cirq.Rz(rads=-12.724144773112773*np.pi).on(q[6]),
          cirq.Rz(rads=12.73446915351482*np.pi).on(q[10]),
          cirq.Rz(rads=11.027652291347495*np.pi).on(q[7]),
          cirq.Rz(rads=-10.570577602838458*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[4], q[8])**-1.0121115249769066,
              cirq.CZ(q[4], q[8])**-0.16059979031178617,
          ],
          [
              cirq.ISWAP(q[5], q[9])**-0.985003985982119,
              cirq.CZ(q[5], q[9])**-0.16606010863938203,
          ],
          [
              cirq.ISWAP(q[6], q[10])**-0.9628319095031052,
              cirq.CZ(q[6], q[10])**-0.16339300450568622,
          ],
          [
              cirq.ISWAP(q[7], q[11])**-0.9999941453695372,
              cirq.CZ(q[7], q[11])**-0.16477879415124544,
          ],
          cirq.Rz(rads=7.826508725663096*np.pi).on(q[4]),
          cirq.Rz(rads=-7.7661951210003215*np.pi).on(q[8]),
          cirq.Rz(rads=12.014531408750791*np.pi).on(q[5]),
          cirq.Rz(rads=-11.988030380246926*np.pi).on(q[9]),
          cirq.Rz(rads=11.590471496440383*np.pi).on(q[6]),
          cirq.Rz(rads=-11.580147116038336*np.pi).on(q[10]),
          cirq.Rz(rads=-11.55701654221442*np.pi).on(q[7]),
          cirq.Rz(rads=12.014091230723457*np.pi).on(q[11]),
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          [cirq.X(q[1])**0.5, cirq.H(q[1])**0.5, cirq.X(q[1])**-0.5],
          cirq.Y(q[2])**0.5,
          [cirq.X(q[3])**0.5, cirq.H(q[3])**0.5, cirq.X(q[3])**-0.5],
          [cirq.X(q[4])**0.5, cirq.H(q[4])**0.5, cirq.X(q[4])**-0.5],
          cirq.X(q[5])**0.5,
          cirq.Y(q[6])**0.5,
          cirq.X(q[7])**0.5,
          cirq.Y(q[8])**0.5,
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          cirq.X(q[10])**0.5,
          [cirq.X(q[11])**0.5, cirq.H(q[11])**0.5, cirq.X(q[11])**-0.5],
          cirq.Rz(rads=26.023597923836856*np.pi).on(q[0]),
          cirq.Rz(rads=-26.106962907913907*np.pi).on(q[4]),
          cirq.Rz(rads=25.356253063938887*np.pi).on(q[1]),
          cirq.Rz(rads=-25.2805848307585*np.pi).on(q[5]),
          cirq.Rz(rads=8.370562501914259*np.pi).on(q[2]),
          cirq.Rz(rads=-8.461596611893802*np.pi).on(q[6]),
          cirq.Rz(rads=10.100639843256841*np.pi).on(q[3]),
          cirq.Rz(rads=-10.099314675186001*np.pi).on(q[7]),
          [
              cirq.ISWAP(q[0], q[4])**-0.933831313649303,
              cirq.CZ(q[0], q[4])**-0.1583933739924931,
          ],
          [
              cirq.ISWAP(q[1], q[5])**-0.9390847780661252,
              cirq.CZ(q[1], q[5])**-0.17144555428591543,
          ],
          [
              cirq.ISWAP(q[2], q[6])**-1.0209160715892363,
              cirq.CZ(q[2], q[6])**-0.14849009270439747,
          ],
          [
              cirq.ISWAP(q[3], q[7])**-1.0287988330229174,
              cirq.CZ(q[3], q[7])**-0.1385888562342036,
          ],
          cirq.Rz(rads=-25.79725021952863*np.pi).on(q[0]),
          cirq.Rz(rads=25.713885235451578*np.pi).on(q[4]),
          cirq.Rz(rads=-24.48288974563276*np.pi).on(q[1]),
          cirq.Rz(rads=24.55855797881315*np.pi).on(q[5]),
          cirq.Rz(rads=-10.07786364079744*np.pi).on(q[2]),
          cirq.Rz(rads=9.986829530817898*np.pi).on(q[6]),
          cirq.Rz(rads=-11.191871460773655*np.pi).on(q[3]),
          cirq.Rz(rads=11.193196628844492*np.pi).on(q[7]),
          cirq.X(q[0])**0.5,
          cirq.X(q[1])**0.5,
          cirq.X(q[2])**0.5,
          cirq.Y(q[3])**0.5,
          cirq.Y(q[4])**0.5,
          [cirq.X(q[5])**0.5, cirq.H(q[5])**0.5, cirq.X(q[5])**-0.5],
          [cirq.X(q[6])**0.5, cirq.H(q[6])**0.5, cirq.X(q[6])**-0.5],
          [cirq.X(q[7])**0.5, cirq.H(q[7])**0.5, cirq.X(q[7])**-0.5],
          [cirq.X(q[8])**0.5, cirq.H(q[8])**0.5, cirq.X(q[8])**-0.5],
          cirq.X(q[9])**0.5,
          [cirq.X(q[10])**0.5, cirq.H(q[10])**0.5, cirq.X(q[10])**-0.5],
          cirq.Y(q[11])**0.5,
          cirq.Rz(rads=10.044737337703173*np.pi).on(q[1]),
          cirq.Rz(rads=-9.952929415695523*np.pi).on(q[2]),
          cirq.Rz(rads=-8.401251133882973*np.pi).on(q[5]),
          cirq.Rz(rads=8.52245467467511*np.pi).on(q[6]),
          cirq.Rz(rads=-6.843134633961698*np.pi).on(q[9]),
          cirq.Rz(rads=6.916407045184491*np.pi).on(q[10]),
          [
              cirq.ISWAP(q[1], q[2])**-1.009868884178167,
              cirq.CZ(q[1], q[2])**-0.16552586798219657,
          ],
          [
              cirq.ISWAP(q[5], q[6])**-0.9733750299685556,
              cirq.CZ(q[5], q[6])**-0.16091330726740966,
          ],
          [
              cirq.ISWAP(q[9], q[10])**-0.9769678680475263,
              cirq.CZ(q[9], q[10])**-0.16332605888196952,
          ],
          cirq.Rz(rads=-10.440214577494247*np.pi).on(q[1]),
          cirq.Rz(rads=10.5320224995019*np.pi).on(q[2]),
          cirq.Rz(rads=8.199075778124648*np.pi).on(q[5]),
          cirq.Rz(rads=-8.07787223733251*np.pi).on(q[6]),
          cirq.Rz(rads=6.561341949396702*np.pi).on(q[9]),
          cirq.Rz(rads=-6.48806953817391*np.pi).on(q[10]),
          cirq.Y(q[0])**0.5,
          cirq.Y(q[1])**0.5,
          cirq.Y(q[2])**0.5,
          cirq.X(q[3])**0.5,
          cirq.X(q[4])**0.5,
          cirq.Y(q[5])**0.5,
          cirq.Y(q[6])**0.5,
          cirq.X(q[7])**0.5,
          cirq.X(q[8])**0.5,
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          cirq.Y(q[10])**0.5,
          [cirq.X(q[11])**0.5, cirq.H(q[11])**0.5, cirq.X(q[11])**-0.5],
          cirq.Rz(rads=12.597359127188014*np.pi).on(q[0]),
          cirq.Rz(rads=-12.538809626368511*np.pi).on(q[1]),
          cirq.Rz(rads=-26.08870806725985*np.pi).on(q[2]),
          cirq.Rz(rads=26.13388826789855*np.pi).on(q[3]),
          cirq.Rz(rads=11.90395452297206*np.pi).on(q[4]),
          cirq.Rz(rads=-11.950266520580142*np.pi).on(q[5]),
          cirq.Rz(rads=-23.906047663366408*np.pi).on(q[6]),
          cirq.Rz(rads=23.945335880513902*np.pi).on(q[7]),
          cirq.Rz(rads=5.221137480344522*np.pi).on(q[8]),
          cirq.Rz(rads=-5.118027941327464*np.pi).on(q[9]),
          cirq.Rz(rads=9.263573798570924*np.pi).on(q[10]),
          cirq.Rz(rads=-9.55041239213535*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[0], q[1])**-0.8242343706275942,
              cirq.CZ(q[0], q[1])**-0.15468164635790926,
          ],
          [
              cirq.ISWAP(q[2], q[3])**-0.981653050634976,
              cirq.CZ(q[2], q[3])**-0.1933349989832593,
          ],
          [
              cirq.ISWAP(q[4], q[5])**-0.9637565510028211,
              cirq.CZ(q[4], q[5])**-0.15186761578643612,
          ],
          [
              cirq.ISWAP(q[6], q[7])**-1.0089894642925605,
              cirq.CZ(q[6], q[7])**-0.17298943435986638,
          ],
          [
              cirq.ISWAP(q[8], q[9])**-0.980271915828302,
              cirq.CZ(q[8], q[9])**-0.16470994863165317,
          ],
          [
              cirq.ISWAP(q[10], q[11])**-0.9290392306402181,
              cirq.CZ(q[10], q[11])**-0.1664963204791881,
          ],
          cirq.Rz(rads=-12.410072351850753*np.pi).on(q[0]),
          cirq.Rz(rads=12.468621852670255*np.pi).on(q[1]),
          cirq.Rz(rads=26.656199817881895*np.pi).on(q[2]),
          cirq.Rz(rads=-26.611019617243198*np.pi).on(q[3]),
          cirq.Rz(rads=-12.422336273583753*np.pi).on(q[4]),
          cirq.Rz(rads=12.376024275975672*np.pi).on(q[5]),
          cirq.Rz(rads=24.032508849527318*np.pi).on(q[6]),
          cirq.Rz(rads=-23.993220632379824*np.pi).on(q[7]),
          cirq.Rz(rads=-5.991658529535789*np.pi).on(q[8]),
          cirq.Rz(rads=6.094768068552847*np.pi).on(q[9]),
          cirq.Rz(rads=-9.293307215154037*np.pi).on(q[10]),
          cirq.Rz(rads=9.006468621589612*np.pi).on(q[11]),
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          cirq.X(q[1])**0.5,
          cirq.X(q[2])**0.5,
          [cirq.X(q[3])**0.5, cirq.H(q[3])**0.5, cirq.X(q[3])**-0.5],
          [cirq.X(q[4])**0.5, cirq.H(q[4])**0.5, cirq.X(q[4])**-0.5],
          cirq.X(q[5])**0.5,
          cirq.X(q[6])**0.5,
          [cirq.X(q[7])**0.5, cirq.H(q[7])**0.5, cirq.X(q[7])**-0.5],
          cirq.Y(q[8])**0.5,
          cirq.Y(q[9])**0.5,
          cirq.X(q[10])**0.5,
          cirq.X(q[11])**0.5,
          cirq.Rz(rads=-13.046692838556257*np.pi).on(q[4]),
          cirq.Rz(rads=13.107006443219033*np.pi).on(q[8]),
          cirq.Rz(rads=-20.486755870544844*np.pi).on(q[5]),
          cirq.Rz(rads=20.51325689904871*np.pi).on(q[9]),
          cirq.Rz(rads=-19.82814477311278*np.pi).on(q[6]),
          cirq.Rz(rads=19.838469153514826*np.pi).on(q[10]),
          cirq.Rz(rads=17.687652291347487*np.pi).on(q[7]),
          cirq.Rz(rads=-17.230577602838448*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[4], q[8])**-1.0121115249769066,
              cirq.CZ(q[4], q[8])**-0.16059979031178617,
          ],
          [
              cirq.ISWAP(q[5], q[9])**-0.985003985982119,
              cirq.CZ(q[5], q[9])**-0.16606010863938203,
          ],
          [
              cirq.ISWAP(q[6], q[10])**-0.9628319095031052,
              cirq.CZ(q[6], q[10])**-0.16339300450568622,
          ],
          [
              cirq.ISWAP(q[7], q[11])**-0.9999941453695372,
              cirq.CZ(q[7], q[11])**-0.16477879415124544,
          ],
          cirq.Rz(rads=12.71050872566315*np.pi).on(q[4]),
          cirq.Rz(rads=-12.650195121000372*np.pi).on(q[8]),
          cirq.Rz(rads=19.562531408750814*np.pi).on(q[5]),
          cirq.Rz(rads=-19.53603038024695*np.pi).on(q[9]),
          cirq.Rz(rads=18.69447149644039*np.pi).on(q[6]),
          cirq.Rz(rads=-18.684147116038343*np.pi).on(q[10]),
          cirq.Rz(rads=-18.21701654221441*np.pi).on(q[7]),
          cirq.Rz(rads=18.674091230723448*np.pi).on(q[11]),
          cirq.Y(q[0])**0.5,
          cirq.Y(q[1])**0.5,
          cirq.Y(q[2])**0.5,
          cirq.Y(q[3])**0.5,
          cirq.X(q[4])**0.5,
          cirq.Y(q[5])**0.5,
          [cirq.X(q[6])**0.5, cirq.H(q[6])**0.5, cirq.X(q[6])**-0.5],
          cirq.Y(q[7])**0.5,
          cirq.X(q[8])**0.5,
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          cirq.Y(q[10])**0.5,
          cirq.Y(q[11])**0.5,
          cirq.Rz(rads=39.34359792383697*np.pi).on(q[0]),
          cirq.Rz(rads=-39.42696290791402*np.pi).on(q[4]),
          cirq.Rz(rads=38.52825306393881*np.pi).on(q[1]),
          cirq.Rz(rads=-38.452584830758425*np.pi).on(q[5]),
          cirq.Rz(rads=12.958562501914345*np.pi).on(q[2]),
          cirq.Rz(rads=-13.049596611893888*np.pi).on(q[6]),
          cirq.Rz(rads=15.428639843256777*np.pi).on(q[3]),
          cirq.Rz(rads=-15.42731467518594*np.pi).on(q[7]),
          [
              cirq.ISWAP(q[0], q[4])**-0.933831313649303,
              cirq.CZ(q[0], q[4])**-0.1583933739924931,
          ],
          [
              cirq.ISWAP(q[1], q[5])**-0.9390847780661252,
              cirq.CZ(q[1], q[5])**-0.17144555428591543,
          ],
          [
              cirq.ISWAP(q[2], q[6])**-1.0209160715892363,
              cirq.CZ(q[2], q[6])**-0.14849009270439747,
          ],
          [
              cirq.ISWAP(q[3], q[7])**-1.0287988330229174,
              cirq.CZ(q[3], q[7])**-0.1385888562342036,
          ],
          cirq.Rz(rads=-39.11725021952874*np.pi).on(q[0]),
          cirq.Rz(rads=39.03388523545169*np.pi).on(q[4]),
          cirq.Rz(rads=-37.65488974563269*np.pi).on(q[1]),
          cirq.Rz(rads=37.730557978813074*np.pi).on(q[5]),
          cirq.Rz(rads=-14.665863640797525*np.pi).on(q[2]),
          cirq.Rz(rads=14.574829530817984*np.pi).on(q[6]),
          cirq.Rz(rads=-16.519871460773594*np.pi).on(q[3]),
          cirq.Rz(rads=16.52119662884443*np.pi).on(q[7]),
          cirq.X(q[0])**0.5,
          cirq.X(q[1])**0.5,
          [cirq.X(q[2])**0.5, cirq.H(q[2])**0.5, cirq.X(q[2])**-0.5],
          cirq.X(q[3])**0.5,
          [cirq.X(q[4])**0.5, cirq.H(q[4])**0.5, cirq.X(q[4])**-0.5],
          cirq.X(q[5])**0.5,
          cirq.X(q[6])**0.5,
          cirq.X(q[7])**0.5,
          cirq.Y(q[8])**0.5,
          cirq.Y(q[9])**0.5,
          [cirq.X(q[10])**0.5, cirq.H(q[10])**0.5, cirq.X(q[10])**-0.5],
          cirq.X(q[11])**0.5,
          cirq.Rz(rads=14.928737337703097*np.pi).on(q[1]),
          cirq.Rz(rads=-14.836929415695444*np.pi).on(q[2]),
          cirq.Rz(rads=-12.10125113388289*np.pi).on(q[5]),
          cirq.Rz(rads=12.22245467467503*np.pi).on(q[6]),
          cirq.Rz(rads=-10.099134633961603*np.pi).on(q[9]),
          cirq.Rz(rads=10.172407045184396*np.pi).on(q[10]),
          [
              cirq.ISWAP(q[1], q[2])**-1.009868884178167,
              cirq.CZ(q[1], q[2])**-0.16552586798219657,
          ],
          [
              cirq.ISWAP(q[5], q[6])**-0.9733750299685556,
              cirq.CZ(q[5], q[6])**-0.16091330726740966,
          ],
          [
              cirq.ISWAP(q[9], q[10])**-0.9769678680475263,
              cirq.CZ(q[9], q[10])**-0.16332605888196952,
          ],
          cirq.Rz(rads=-15.32421457749417*np.pi).on(q[1]),
          cirq.Rz(rads=15.416022499501823*np.pi).on(q[2]),
          cirq.Rz(rads=11.899075778124569*np.pi).on(q[5]),
          cirq.Rz(rads=-11.777872237332431*np.pi).on(q[6]),
          cirq.Rz(rads=9.817341949396608*np.pi).on(q[9]),
          cirq.Rz(rads=-9.744069538173814*np.pi).on(q[10]),
          cirq.Y(q[0])**0.5,
          cirq.Y(q[1])**0.5,
          cirq.Y(q[2])**0.5,
          [cirq.X(q[3])**0.5, cirq.H(q[3])**0.5, cirq.X(q[3])**-0.5],
          cirq.Y(q[4])**0.5,
          cirq.Y(q[5])**0.5,
          [cirq.X(q[6])**0.5, cirq.H(q[6])**0.5, cirq.X(q[6])**-0.5],
          [cirq.X(q[7])**0.5, cirq.H(q[7])**0.5, cirq.X(q[7])**-0.5],
          cirq.X(q[8])**0.5,
          [cirq.X(q[9])**0.5, cirq.H(q[9])**0.5, cirq.X(q[9])**-0.5],
          cirq.Y(q[10])**0.5,
          cirq.Y(q[11])**0.5,
          cirq.Rz(rads=17.629359127188117*np.pi).on(q[0]),
          cirq.Rz(rads=-17.570809626368614*np.pi).on(q[1]),
          cirq.Rz(rads=-36.89270806725978*np.pi).on(q[2]),
          cirq.Rz(rads=36.93788826789848*np.pi).on(q[3]),
          cirq.Rz(rads=16.787954522971983*np.pi).on(q[4]),
          cirq.Rz(rads=-16.834266520580062*np.pi).on(q[5]),
          cirq.Rz(rads=-33.970047663366486*np.pi).on(q[6]),
          cirq.Rz(rads=34.00933588051398*np.pi).on(q[7]),
          cirq.Rz(rads=7.441137480344476*np.pi).on(q[8]),
          cirq.Rz(rads=-7.338027941327417*np.pi).on(q[9]),
          cirq.Rz(rads=12.963573798570843*np.pi).on(q[10]),
          cirq.Rz(rads=-13.250412392135269*np.pi).on(q[11]),
          [
              cirq.ISWAP(q[0], q[1])**-0.8242343706275942,
              cirq.CZ(q[0], q[1])**-0.15468164635790926,
          ],
          [
              cirq.ISWAP(q[2], q[3])**-0.981653050634976,
              cirq.CZ(q[2], q[3])**-0.1933349989832593,
          ],
          [
              cirq.ISWAP(q[4], q[5])**-0.9637565510028211,
              cirq.CZ(q[4], q[5])**-0.15186761578643612,
          ],
          [
              cirq.ISWAP(q[6], q[7])**-1.0089894642925605,
              cirq.CZ(q[6], q[7])**-0.17298943435986638,
          ],
          [
              cirq.ISWAP(q[8], q[9])**-0.980271915828302,
              cirq.CZ(q[8], q[9])**-0.16470994863165317,
          ],
          [
              cirq.ISWAP(q[10], q[11])**-0.9290392306402181,
              cirq.CZ(q[10], q[11])**-0.1664963204791881,
          ],
          cirq.Rz(rads=-17.442072351850854*np.pi).on(q[0]),
          cirq.Rz(rads=17.500621852670356*np.pi).on(q[1]),
          cirq.Rz(rads=37.46019981788182*np.pi).on(q[2]),
          cirq.Rz(rads=-37.415019617243125*np.pi).on(q[3]),
          cirq.Rz(rads=-17.306336273583675*np.pi).on(q[4]),
          cirq.Rz(rads=17.260024275975592*np.pi).on(q[5]),
          cirq.Rz(rads=34.09650884952739*np.pi).on(q[6]),
          cirq.Rz(rads=-34.057220632379895*np.pi).on(q[7]),
          cirq.Rz(rads=-8.211658529535743*np.pi).on(q[8]),
          cirq.Rz(rads=8.3147680685528*np.pi).on(q[9]),
          cirq.Rz(rads=-12.993307215153958*np.pi).on(q[10]),
          cirq.Rz(rads=12.706468621589535*np.pi).on(q[11]),
          [cirq.X(q[0])**0.5, cirq.H(q[0])**0.5, cirq.X(q[0])**-0.5],
          cirq.X(q[1])**0.5,
          cirq.X(q[2])**0.5,
          cirq.X(q[3])**0.5,
          cirq.X(q[4])**0.5,
          [cirq.X(q[5])**0.5, cirq.H(q[5])**0.5, cirq.X(q[5])**-0.5],
          cirq.X(q[6])**0.5,
          cirq.Y(q[7])**0.5,
          cirq.Y(q[8])**0.5,
          cirq.Y(q[9])**0.5,
          [cirq.X(q[10])**0.5, cirq.H(q[10])**0.5, cirq.X(q[10])**-0.5],
          cirq.X(q[11])**0.5,
      ],
      strategy=cirq.InsertStrategy.EARLIEST)
  return circuit


def main(argv):
  if len(argv) > 1:
    raise app.UsageError('Too many command-line arguments.')

  circuit = get_circuit()
  logging.info(circuit)
  probabilities = get_probabilities(circuit)
  logging.info(probabilities)


if __name__ == '__main__':
  app.run(main)
